/*
 *  Copyright 2010 Wesley Gooch, Ryan Nix, Cody Wenzel.
 *  Montana State University - Spring Semester 2010
 *  Computer Science 450 - Compilers
 *  Project: Micro-Pascal Compiler
 */

package msu.compiler.semantics;

import msu.compiler.scanner.Token;

/**
 *
 * @author wenzel
 */
public abstract class Symbol {
    // Allowed Types for Micro Pascal:
    public static final byte TYPE_INT = 0;
    public static final byte TYPE_FLOAT = 1;
    public static final byte TYPE_BOOLEAN = 2;
    // May need to add more here eventually...

    protected byte type;

    protected Token token;
    protected byte size = 1;//Hardcode because we know size is always one
    protected byte offset;

    protected String kind;
    protected String label = " "; //initialize to no label
    
    public Symbol(Token token, byte type, String kind){
        this.token = token;
        this.type = type;
        this.kind = kind;
    }

    public Symbol(Token token, byte type, String kind, String label){
        this.token = token;
        this.type = type;
        this.kind = kind;
        this.label = label;
    }

    public String getLexeme(){
        return token.getLexeme();
    }

    public Token getToken() {
        return token;
    }
    
    public byte getType() {
        return type;
    }

    public byte getOffset(){
        return offset;
    }

    public void setOffset(byte os){
        offset = os;
    }

    public String getKind(){
        return kind;
    }

    public String getLabel(){
        return label;
    }

    public String getTypeString(){
        switch(type){
            case TYPE_INT:
                return "INT";
            case TYPE_FLOAT:
                return "FLOAT";
            case TYPE_BOOLEAN:
                return "BOOLEAN";
            default:
                return null;
        }
    }
}
